<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/js/upload.js"></script>
<script>
    function ajaxFileUpload()
    {
        var doing = '';
        $("#loading")   
            .ajaxStart(function(){
                $(this).show();
                document.getElementById('logo').innerHTML="图片上传中……";
            })
            .ajaxComplete(function(){
                $(this).hide();
                document.getElementById('logo').innerHTML= doing;
            });
        $.ajaxFileUpload
        (
            {
                url:'upload_image.php',
                secureuri:false,
                fileElementId:'file',
                dataType: 'json',
                data:{name:'logan', id:'id'},
                success: function (data, status)
                {
                    //alert(data);
                    data=data.replace('<pre>','');
                    data=data.replace('</pre>','');
                    var info=data.split('|');
                    if(info[0]=="E")
                        alert(info[1]);
                    else{
                        //上传多张图片的代码
                        /*						var c = $("#upd_pics").html();
                         $("#upd_pics").html(c +
                         "<p><img src='"+ info[1] +"' width='100px'> <input type='checkbox' checked name='pics[]' value="+ info[1] +" /> "+info[1]
                         +"</p>");
                         var pic_url=info[1];*/
                        $("#upd_pics").html(
                            "<p><img src='"+ info[1] +"' width='100px'> <input type='checkbox' checked name='pics' value="+ info[1] +" /> "+info[1]
                            +"</p>");
                        /*$.ajax({
                         url: "uploadPic_ajax.php",
                         type: "POST",
                         data:{url:pic_url},
                         dataType: "json",
                         error: function(){},
                         success: function(data){ }
                         });*/
                    }
                },
                error: function (data, status, e)
                {
                    alert(e);
                }
            }
        )
        return false;
    }
    function check_file() {
        $("#spanMsg").html('');
    }
    function exportClick() {
        $("#spanMsg").html('');
        if ($("#file").val() == '') {
            alert('请先选择要导入的文件');
            return false;
    }
    }
    $(function(){
    });
</script>
<p>图片上传:
    <span id="upd_pics"></span>
    <input type="file" name="file" id="file" onchange="check_file()"/>
	 	<span id="loading" style="display:none;">
	 	<img src="../images/loading.gif" alt="loading...">
	 	</span>
    <span id="logo"></span>
    <input type="hidden" name="filename" id="filename" value="" />
    <input type="hidden" name="goods_desc" id="goods_desc" value="" />
    <input type="button" value="上传" onclick="return ajaxFileUpload();"
           class="btn btn-large btn-primary" />
</p>